Ext.namespace("GridParkInfo");
GridParkInfo.Detail = function() {
	this.userSelector = null;
	this.selectUserId = null;
	this.users = [];
	
	this.txtParkId = new Ext.form.Hidden({
		name:'ParkId'
	});
	//营销单元id
	this.txtUnitId = new Ext.form.Hidden({
		name:'UnitId',
		value:''
	});
	this.txtGridId = new Ext.form.Hidden({
		name:'gridId'
	});
	//园区名称
	this.txtParkName = new Ext.form.TextField({
		fieldLabel : '基地园区名称<font color="red">*</font>',
		name :'ParkName',
		width : 400,
		maxLength : 10,
		allowBlank:false
	});
	//园区类型
	this.cmbParkType = new Ext.form.ComboBox({
        width: 120,
        fieldLabel: '基地园区类型',
        store: OMS.GRID_NC_TYPE,
        editable: false,
        typeAhead:true,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true
    });
	
	//园区楼宇数量
	this.txtBuildingNum = new Ext.form.NumberField({
		fieldLabel: '楼宇数量',
		name : 'buildingNum',
		width: 120,
		maxLength : 8
	});
	//基地园区总户数
    this.txtTotalDoorNum = new Ext.form.NumberField({
		fieldLabel : '总商户数',
		name : 'totalDoorNum',
		width : 120,
		maxLength : 8
	});
	
	//基地园区入住率
	this.txtOccupancyRate = new Ext.form.TextField({
		fieldLabel : '商户入住率<font color="red">*</font>',
		name :'occupancyRate',
		width : 120,
		maxLength : 10
	});
	 //基地园区商铺招商方向
	this.cmbAttractInvestment = new Ext.form.TextField({
        width: 120,
        maxLength : 10,
        fieldLabel: '商铺招商方向'
    });
	//基地园区商铺单价 
	this.txtMerchantUnitPrice = new Ext.form.TextField({
		fieldLabel : '商铺单价 ',
		name :'merchantUnitPrice',
		width : 120,
		maxLength : 8
	});
	//基地园区车位数量
	this.txtGarageNum = new Ext.form.NumberField({
		fieldLabel : '车位数量',
		name :'garageNum',
		width : 120,
		maxLength : 8
	});
	//排名第一行业
    this.cmbFirstIndustry = new Ext.form.ComboBox({
        width: 80,
        fieldLabel: '排名第一行业',
        name : 'firstIndustry',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data:OMS.GRIDBUILDING_INDUSTRY
        }),
        valueField: 'value',
        displayField: 'name',
        editable: false,
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    this.txtFirstIndustryPer = new Ext.form.NumberField({
    	fieldLabel : '占比',
    	name : 'firstIndustryPer',
		width : 80,
		maxLength : 8
    });
    //排名第二行业
    this.cmbSecondIndustry = new Ext.form.ComboBox({
        width: 80,
        fieldLabel: '排名第一行业',
        name : 'secondIndustry',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRIDBUILDING_INDUSTRY
        }),
        valueField: 'value',
        editable: false,
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    this.txtSecondIndustryPer = new Ext.form.NumberField({
    	fieldLabel : '占比',
    	name : 'secondIndustryPer',
		width : 80,
		maxLength : 8
    });
    //排名第三行业
    this.cmbThirdIndustry = new Ext.form.ComboBox({
        width: 80,
        fieldLabel: '排名第一行业',
        name : 'thirdIndustry',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GRIDBUILDING_INDUSTRY
        }),
        valueField: 'value',
        editable: false,
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    this.txtThirdIndustryPer = new Ext.form.NumberField({
    	fieldLabel : '占比',
    	name : 'thirdIndustryPer',
		width : 80,
		maxLength : 8
    });
    //客户经理ID
	this.txtUnitManagerUserId = new Ext.form .Hidden({
    	name : 'unitManagerUser.branchId'
    });
    	//客户经理
    this.txtUnitManager = new Ext.form.TextField({
		fieldLabel: '客户经理<font color="red">*</font>',
		readOnly: true,
		name : 'unitManagerUser.userName',
		width: 120,
		listeners: {
		'render': function(cmp) {
				var self = cmp.ownerCt.ownerCt.ownerCt.ownerCt.ownerCt;
				//console.info(self)
				cmp.getEl().on('click', self.showSelector, self); 
			}
		}
	});
	//联系方式
	 this.txtUnitManagerPhone = new Ext.form.NumberField({
    	fieldLabel : '联系方式',
    	name : 'userPhone',
		width : 120,
		maxLength : 15
    });
    //行政区县
	this.cmbProvince = new Ext.form.ComboBox({
		width : 120,
        fieldLabel : '行政区县',
//      hiddenName : 'addressInfo.province',
        store: ['浦东新区'],
        typeAhead:true,
        editable: false,
        mode: 'local',
        triggerAction: 'all',
        selectOnFocus: true	
	});
	//街道路段
	this.txtAddressInfoNeighbourhood = new Ext.form.TextField({
		fieldLabel : '街道路段',
		name : 'neighbourhood',
		width : 120,
		maxLength : 10
	});
	//地址-路
	this.txtAddressId = new Ext.form.Hidden({
		name : 'AddressId'
	});
	this.txtAddressInfoStreet = new Ext.form.TextField({
		fieldLabel : '地址 路<font color="red">*</font>',
		name :'street',
		width : 120,
		maxLength : 10
	});
	//弄
	this.txtAddressInfoAlley = new Ext.form.NumberField({
		fieldLabel: '弄<font color="red">*</font>',
		name :'alley',
		width: 60,
		maxLength : 10
	});
	//号
	this.txtAddressInfoDoorNum = new Ext.form.NumberField({
		fieldLabel: '号<font color="red">*</font>',
		name :'doorNum',
		width: 60,
		maxLength : 10
	});
	//商铺数
	this.shopNum = new Ext.form.NumberField({
		fieldLabel: '商铺数<font color="red">*</font> ',
		name :'shopNum',
		width: 120,
		maxLength : 10
	});		

  //基站
	this.baseStation = new Ext.form.TextField({
		fieldLabel : '基站<font color="red">*</font> ',
		name : 'baseStation',
		width : 120,
		maxLength : 100
	});
	//管委会
	this.managementCommittee = new Ext.form.TextField({
		fieldLabel : '管委会<font color="red">*</font> ',
		name : 'managementCommittee',
		width : 120,
		maxLength : 100
	});
	//附件传输资源点  	
	this.nearlyResource = new Ext.form.TextField({
		fieldLabel : '附近传输资源点 <font color="red">*</font> ',
		name : 'nearlyResource',
		width : 120,
		maxLength : 100
	});
	//最近的营业厅名称
	this.nearlyHallName = new Ext.form.TextField({
		fieldLabel : '最近的营业厅名称<font color="red">*</font> ',
		name : 'nearlyHallName',
		width : 120,
		maxLength : 100
	});

	//基本信息
	this.form = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//fileUpload: true, 
		autoScroll : true,
		//autoHeight : true,
		height: 390,
		width : 750,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:2},
		items:[
			{colspan:2,layout:'form',items:[this.txtParkName]},
			{layout:'form',items:[this.txtBuildingNum]},			
            {layout:'form', items:[this.txtTotalDoorNum]}, 
            {layout:'form',items:[this.cmbParkType]},	
            {layout:'form', items:[this.cmbAttractInvestment]}, 
            {layout:'form', items:[this.txtOccupancyRate]},
            {layout:'form', items:[this.txtMerchantUnitPrice]},
            {layout:'form',items:[this.cmbFirstIndustry]},
			{layout:'form',items:[this.txtFirstIndustryPer]},
			{layout:'form',items:[this.cmbSecondIndustry]},
			{layout:'form',items:[this.txtSecondIndustryPer]},
			{layout:'form',items:[this.cmbThirdIndustry]},
			{layout:'form',items:[this.txtThirdIndustryPer]},
			{layout:'form', items:[this.txtUnitManager]},
            //{layout:'form', items:[this.txtUnitManagerPhone]},
             {layout:'form', items:[this.txtGarageNum]},
            {rowspan:3,layout:'form',items:[
            			{layout:'form',items:this.txtAddressInfoStreet},
            			{layout:'form',items:this.txtAddressInfoAlley},
            			{layout:'form',items:this.txtAddressInfoDoorNum}
            			]},
            {layout:'form', items:[this.cmbProvince]},
            {layout:'form', items:[this.txtAddressInfoNeighbourhood]},
			{layout:'form', items:[this.txtGridId]},
			{layout:'form', items:[this.shopNum]},
			{layout:'form', items:[this.baseStation]},
			{layout:'form', items:[this.managementCommittee]},
			{layout:'form', items:[this.nearlyResource]},
			{layout:'form', items:[this.nearlyHallName]},
			{layout:'form', items:[this.txtParkId]}
		]
	});
		////物业信息
    //物业公司名称 
    this.txtPropertyCompany = new Ext.form .Hidden({
    	name : 'propertyCompany'
    });
    
    this.txtCompanyInfoCustName  = new Ext.form.TextField({
    	fieldLabel : '物业公司名称',
    	name : 'custName',
		width : 120,
		maxLength : 25
    });
    
     //物业公司联系人1
    this.txtPmContactInfoContactId = new Ext.form .Hidden({
    	name : 'pmContactInfo.contactId'
    });
    this.txtPmContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人1',
    	name : 'pmContactInfo.userName',
		width : 120,
		maxLength : 25
    });
    this.txtPmContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人1职位',
    	name : 'pmContactInfo.position',
		width : 120,
		maxLength : 25
    });
    //办公电话
    this.txtPmContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人1办公电话',
    	name : 'pmContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
   this.txtPmContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人1移动电话',
    	name : 'pmContactInfo. ',
		width : 120,
		maxLength : 15
    });
    //物业公司物业公司联系人2
    this.txtPbContactInfoContactId = new Ext.form.Hidden({
    	name : 'pbContactInfo.contactId'
    });
    this.txtPbContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人2',
    	name : 'pbContactInfo.userName',
		width : 120,
		maxLength : 25
    });
     this.txtPbContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人2职位',
    	name : 'pbContactInfo.position',
		width : 120,
		maxLength : 25
    });
    //办公电话
    this.txtPbContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人2办公电话',
    	name : 'pbContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
    this.txtPbContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人2移动电话',
    	name : 'pbContactInfo.mobileNumber',
		width : 120,
		maxLength : 15
    });
    //物业公司联系人3
     this.txtPpContactInfoContactId = new Ext.form.Hidden({
    	name : 'ppContactInfo.contactId'
    });
    this.txtPpContactInfoUserName = new Ext.form.TextField({
    	fieldLabel : '物业公司联系人3',
    	name : 'ppContactInfo.userName',
		width : 120,
		maxLength : 25
    });
    this.txtPpContactInfoPosition = new Ext.form.TextField({
    	fieldLabel : '联系人3职位',
    	name : 'ppContactInfo.position',
		width : 120,
		maxLength : 25
    });
    
    //办公电话
    this.txtPpContactInfoPhoneNumOffice = new Ext.form.NumberField({
    	fieldLabel : '联系人3办公电话',
    	name : 'ppContactInfo.phoneNumOffice',
		width : 120,
		maxLength : 15
    });
     //移动电话
    this.txtPpContactInfoMobileNumber = new Ext.form.NumberField({
    	fieldLabel : '联系人3移动电话',
    	name : 'ppContactInfo.mobileNumber',
		width : 120,
		maxLength : 15
    });
    this.formFieldSet1 = new Ext.form.FieldSet({
	        title: '联系人1',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	        	{colspan:1,layout:'form', items:[this.txtPmContactInfoPosition]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPmContactInfoContactId]}
			]
		});
	this.formFieldSet2 = new Ext.form.FieldSet({
	        title: '联系人2',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	       		{colspan:1,layout:'form', items:[this.txtPbContactInfoPosition]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPbContactInfoContactId]}
			]
		});
	this.formFieldSet3 = new Ext.form.FieldSet({
	        title: '联系人3',
	        layout:'table',
	        autoHeight: true,
	        labelAlign:'right',
	        layoutConfig:{columns:2},
	        items:[
	        	{colspan:1,layout:'form', items:[this.txtPpContactInfoPosition]},
	        	{colspan:1,layout:'form', items:[this.txtPpContactInfoUserName]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoPhoneNumOffice]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoMobileNumber]},
				{colspan:1,layout:'form', items:[this.txtPpContactInfoContactId]}
			]
		});
    //物业信息---FormPanel
    this.contactInfoForm = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//autoHeight : true,
		height:420,
		align:'center',
		width : 700,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:1},
		items:[
			{colspan:1,layout:'form', items:[this.txtPropertyCompany]},
			{colspan:1,layout:'form', items:[this.txtCompanyInfoCustName]},
			this.formFieldSet1,this.formFieldSet2,this.formFieldSet3
		]
	});	
	//GIS信息
	this.txtGisId = new Ext.form.Hidden({
		name: 'gisInfo.id'
	});
	
	this.txtGisType = new Ext.form.Hidden({
		name: 'gisInfo.type',
		value: 1
	});
	//所属网格
	this.cmbGrid= new Ext.form.ComboBox({
		width :120,
		listWidth:135,
        fieldLabel: '所属网格',
        name : 'gridId',
        store : new Ext.data.JsonStore({
		   url:"../gridareas/listGrid.form",
		   autoLoad : true,
		   root:"grids",
		   fields:["gridId","gridName"]
		}),
		valueField : 'gridId',
		editable: false,
		displayField :'gridName',
        mode: 'local',
        //typeAhead:true,
        emptyText:'请选择所属网格',
        triggerAction: 'all',
        selectOnFocus: true
	});
	//所属区域
	this.cmbRegion = new Ext.form.ComboBox({
		width :120,
		listWidth:135,
		allowBlank : true,
		blankText:'请选择所属区域',
		fieldLabel: '所属区域',
		store : new Ext.data.JsonStore({
		   url:'../gridareas/listAllRegions.form',
		   autoLoad : true,
		   root:"regions",
		   fields:["areaId","name"]
		}),
		valueField : 'areaId',
		displayField :'name',
		editable: false,
        mode: 'local',
		triggerAction :'all',
		emptyText :'请选择所在区域',
		selectOnFocus :true	
	});
	 //坐标
    this.txtCoordsInfo = new Ext.form.TextArea({
		fieldLabel : '基地园区坐标',
		preventScrollbars : true,
		name :'coordsInfo',
		width : 400,
		heigth : 350
    });
    
    this.txtGroupCustInfoID = new Ext.form.Hidden({
    	name:'marketIdInfo'
    });
    
    //基地园区边框颜色
    this.txtLineColor = new Ext.form.ComboBox({
    	width :120,
		listWidth:135,
        fieldLabel: '边框颜色',
        name : 'LineColor',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GIS_COLOR
        }),
        valueField: 'value',
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    
    //园区填充颜色
    this.txtMainFillColor = new Ext.form.ComboBox({
    	width :120,
		listWidth:135,
        fieldLabel: '填充颜色',
        name : 'MainFillColor',
        store: new Ext.data.SimpleStore({
        	fields: ['value', 'name'],
        	data: OMS.GIS_COLOR
        }),
        valueField: 'value',
        displayField: 'name',
        typeAhead:true,
        mode: 'local',
        emptyText:'---请选择---',
        triggerAction: 'all',
        selectOnFocus: true
    });
    //绘制园区
    this.btnDrawGis = new Ext.Button({
        text: '绘制园区',
        tooltip: {text: '绘制园区'},
        handler: this.viewGis,
        scope: this
    });
    
    //GIS信息--FormPanel
    this.gisform = new Ext.form.FormPanel({
		bodyStyle : 'padding: 5px 5px 0',
		frame :true,
		//autoHeight : true,
		height:420,
		id : 'gisForm',
//		disabled : true,
		width : 700,
		labelAlign: 'right',
		labelWidth : 120,
		layout : 'table',
		layoutConfig : {columns:2},
		items:[
		    {layout:'form',items:[this.cmbRegion]},
		    {layout:'form',items:[this.cmbGrid]},
			{layout:'form', items:[this.txtLineColor]},
			{layout:'form', items:[this.txtMainFillColor]},
			{colspan:2,layout:'form', items:[this.txtCoordsInfo]},
			{layout:'form', items:[this.txtGisType]},
            {colspan:2,layout:'form', items:[this.btnDrawGis]},
            {layout:'form', items:[this.txtGisId]}
		]
	});
    
	 this.tabs = new Ext.TabPanel({
        width:700,
        activeTab: 0,
        frame:true,
        //autoHeight:true,
        height : 420,
        deferredRender:false, 
		layoutOnTabChange:true,
        items:[
            {items:this.form, title: '基本信息'},
            {items:this.contactInfoForm, title: '物业信息'},
            {items:this.gisform, title: 'Gis信息'}
        ]
    });
    
	GridParkInfo.Detail.superclass.constructor.call(this,{
		title : '基地园区信息',
		bodyStyle: 'padding: 5px 5px 0',
        autoHeight: true,
        width: 750,
        resizable: false,
        plain: true,
        modal: true,
        layout:'form',
        autoScroll: true,
        closeAction: 'hide',
        items :[this.tabs],
        buttons: [{
            text: '保存',
            cls: 'x-btn-text-icon btn-save',
            handler: this.onSave,
            scope: this
        }, {
            text: '关闭',
            cls: 'x-btn-text-icon btn-cancel',
            handler: this.hide.createDelegate(this, [])
        }]
		
	});
};

Ext.extend(GridParkInfo.Detail,Ext.Window,{
		initAdd :function(){
			this.form.getForm().reset();
			this.gisform.getForm().reset();
			this.contactInfoForm.getForm().reset();
		},
		initEdit : function(data){
			this.form.getForm().reset();
			this.gisform.getForm().reset();
			this.contactInfoForm.getForm().reset();
			Ext.Ajax.request({
				url: '../gridparkinfo/prepare.form?timesnap=' + Date.parse(new Date()),
				method: 'POST',
				scope:this,
				params: {
					park_id : data.PARK_ID,
					unit_manager : data.UNIT_MANAGER,
					gis_id : data.GIS_ID,
					address_id : data.ADDRESS_ID,
					unit_id : data.UNIT_ID,
					property_company : data.PROPERTY_COMPANY
					//entity_id : data.ENTITY_ID
					//entity_type :data.ENTITY_TYPE,
					//contact_type : data.CONTACT_TYPE
				},
				success:function(resp){	
					var resp = Ext.util.JSON.decode(resp.responseText);
					//基本信息
					if(resp.park){
						this.txtParkId.setValue(resp.park[0].PARK_ID);
						this.txtUnitId.setValue(resp.park[0].UNIT_ID);		
						this.txtParkName.setValue(resp.park[0].PARK_NAME);			
						this.txtBuildingNum.setValue(resp.park[0].BUILDING_NUM);			
						this.txtTotalDoorNum.setValue(resp.park[0].TOTAL_DOOR_NUM);
						this.cmbParkType.setValue(resp.park[0].PARK_TYPE);
						this.cmbAttractInvestment.setValue(resp.park[0].ATTRACT_INVESTMENT);
						this.txtOccupancyRate.setValue(resp.park[0].OCCUPANCY_RATE);			
						this.txtMerchantUnitPrice.setValue(resp.park[0].MERCHANT_UNIT_PRICE);
						this.txtGarageNum.setValue(resp.park[0].GARAGE_NUM);			
						this.txtPropertyCompany.setValue(resp.park[0].PROPERTY_COMPANY);
						this.cmbFirstIndustry.setValue(resp.park[0].FIRST_INDUSTRY);
						this.txtFirstIndustryPer.setValue(resp.park[0].FIRST_INDUSTRY_PER);
						this.cmbSecondIndustry.setValue(resp.park[0].SECOND_INDUSTRY);
						this.txtSecondIndustryPer.setValue(resp.park[0].SECOND_INDUSTRY_PER);
						this.cmbThirdIndustry.setValue(resp.park[0].THIRD_INDUSTRY);
						this.txtThirdIndustryPer.setValue(resp.park[0].THIRD_INDUSTRY_PER);
						
						this.baseStation.setValue(resp.park[0].BASE_STATION);
						this.managementCommittee.setValue(resp.park[0].MANAGEMENT_COMMITTEE);
						this.nearlyResource.setValue(resp.park[0].NEARLY_RESOURCE);
						this.shopNum.setValue(resp.park[0].SHOP_NUM);
						
					}
					if(resp.unit_manager[0]){
						this.txtUnitManagerUserId.setValue(resp.unit_manager[0].USER_ID);
						this.txtUnitManager.setValue(resp.unit_manager[0].USER_NAME);
						this.txtUnitManagerPhone.setValue(resp.unit_manager[0].USER_PHONE);
					}
					if(resp.unit){
						this.txtGridId.setValue(resp.unit[0].GRID_ID);	
						this.txtAddressId.setValue(resp.unit[0].ADDRESS_ID);
						this.nearlyHallName.setValue(resp.unit[0].NEARLY_HALL_NAME);
						this.cmbRegion.setValue(resp.unit[0].AREA_ID);
						this.cmbGrid.setValue(resp.unit[0].GRID_ID);
					}
					if(resp.address){
						this.txtAddressInfoStreet.setValue(resp.address[0].STREET);
						this.txtAddressInfoAlley.setValue(resp.address[0].ALLEY);
						this.txtAddressInfoDoorNum.setValue(resp.address[0].DOOR_NUM);
						this.cmbProvince.setValue(resp.address[0].DISTRICT);
						this.txtAddressInfoNeighbourhood.setValue(resp.address[0].NEIGHBOURHOOD);
					}
					//gis信息
					/*this.cmbDistrict.setValue(resp.park[0].GRID);
					this.txtAddressInfoLongitude.setValue(resp.address[0].LONGITUDE);
					this.txtAddressInfoLatitude.setValue(resp.address[0].LATITUDE);
					this.txtGisIconId.setValue(resp.gis[0].ICON_ID);*/
					if(resp.gis){
						this.txtGisId.setValue(resp.gis[0].GIS_ID);
						this.txtCoordsInfo.setValue(resp.gis[0].COORDS_INFO);
						this.txtLineColor.setValue(resp.gis[0].LINE_COLOR);
						this.txtMainFillColor.setValue(resp.gis[0].MAIN_FILL_COLOR);
						this.txtGisType.setValue(resp.gis[0].TYPE);
					}
					//物业信息
					if(resp.property_company[0]){
						this.txtPropertyCompany.setValue(resp.property_company[0].CUST_ID);
						this.txtCompanyInfoCustName.setValue(resp.property_company[0].CUST_NAME);
					}
					if(resp.pmContactInfo){
						this.txtPmContactInfoContactId.setValue(resp.pmContactInfo.CONTACT_ID);
						this.txtPmContactInfoUserName.setValue(resp.pmContactInfo.USER_NAME);
						this.txtPmContactInfoPosition.setValue(resp.pmContactInfo.POSITION);
						this.txtPmContactInfoPhoneNumOffice.setValue(resp.pmContactInfo.PHONE_NUM_OFFICE);
						this.txtPmContactInfoMobileNumber.setValue(resp.pmContactInfo.MOBILE_NUMBER);
					}
					if(resp.pbContactInfo){
						this.txtPbContactInfoContactId.setValue(resp.pbContactInfo.CONTACT_ID);
						this.txtPbContactInfoPosition.setValue(resp.pbContactInfo.POSITION);
						this.txtPbContactInfoUserName.setValue(resp.pbContactInfo.USER_NAME);
						this.txtPbContactInfoPhoneNumOffice.setValue(resp.pbContactInfo.PHONE_NUM_OFFICE);
						this.txtPbContactInfoMobileNumber.setValue(resp.pbContactInfo.MOBILE_NUMBER);
					}
					if(resp.ppContactInfo){
						this.txtPpContactInfoContactId.setValue(resp.ppContactInfo.CONTACT_ID);
						this.txtPpContactInfoPosition.setValue(resp.ppContactInfo.POSITION);
						this.txtPpContactInfoUserName.setValue(resp.ppContactInfo.USER_NAME);
						this.txtPpContactInfoPhoneNumOffice.setValue(resp.ppContactInfo.PHONE_NUM_OFFICE);
						this.txtPpContactInfoMobileNumber.setValue(resp.ppContactInfo.MOBILE_NUMBER);
					}
				},
				failure:function(resp){	
					Utils.info('操作失败!','系统提示');
					return;
				}
			});
		},
		onSave:function(){
			if(!this.form.getForm().isValid()){
				Utils.info("信息填写不完整或有误,请检查!","系统提示");
				return;
			}
			this.conn =new Ext.data.Connection({
		        method: 'POST',
		        url: '../gridparkinfo/save.form?timesnap=' + Date.parse(new Date())
		    });
			Utils.request(this.conn,{
				scope: this,
				params: {
					//基本信息
					park_id:this.txtParkId.getValue(),
					grid_id:this.txtGridId.getValue(),
					unit_id :this.txtUnitId.getValue(),
					park_name :this.txtParkName.getValue(),
					park_type :this.cmbParkType.getValue(),
					building_num :this.txtBuildingNum.getValue(),
					total_door_num :this.txtTotalDoorNum.getValue(),
					occupancy_rate :this.txtOccupancyRate.getValue(),
					attract_investment :this.cmbAttractInvestment.getValue(),
					merchant_unit_price :this.txtMerchantUnitPrice.getValue(),
					garage_num :this.txtGarageNum.getValue(),
					property_company :this.txtPropertyCompany.getValue(),
					first_industry :this.cmbFirstIndustry.getValue(),
					first_industry_per :this.txtFirstIndustryPer.getValue(),
					second_industry :this.cmbSecondIndustry.getValue(),
					second_industry_per :this.txtSecondIndustryPer.getValue(),
					third_industry :this.cmbThirdIndustry.getValue(),
					third_industry_per :this.txtThirdIndustryPer.getValue(),
					
					unit_manager_user_id:this.txtUnitManagerUserId.getValue(),
					unit_manager_user_name:this.txtUnitManager.getValue(),
					unit_manager_user_phone:this.txtUnitManagerPhone.getValue(),
					
					address_id:this.txtAddressId.getValue(),
					
					street:this.txtAddressInfoStreet.getValue(),
					alley:this.txtAddressInfoAlley.getValue(),
					door_num:this.txtAddressInfoDoorNum.getValue(),
					district:this.cmbProvince.getValue(),
					neighbourhood:this.txtAddressInfoNeighbourhood.getValue(),

					pmcontactinfo_user_name:this.txtPmContactInfoUserName.getValue(),
					pmcontactinfo_user_position:this.txtPmContactInfoPosition.getValue(),
					pmcontactinfo_phone_num_office:this.txtPmContactInfoPhoneNumOffice.getValue(),
					pmcontactinfo_mobile_number:this.txtPmContactInfoMobileNumber.getValue(),
					
					pbcontactinfo_user_name:this.txtPbContactInfoUserName.getValue(),
					pbcontactinfo_user_position:this.txtPbContactInfoPosition.getValue(),
					pbcontactinfo_phone_num_office:this.txtPbContactInfoPhoneNumOffice.getValue(),
					pbcontactinfo_mobile_number:this.txtPbContactInfoMobileNumber.getValue(),
					
					ppcontactinfo_user_name:this.txtPpContactInfoUserName.getValue(),
					ppcontactinfo_user_position:this.txtPpContactInfoPosition.getValue(),
					ppcontactinfo_phone_num_office:this.txtPpContactInfoPhoneNumOffice.getValue(),
					ppcontactinfo_mobile_number:this.txtPpContactInfoMobileNumber.getValue(),
					
					pmcontactinfo_contact_id:this.txtPmContactInfoContactId.getValue(),
					pbcontactinfo_contact_id:this.txtPbContactInfoContactId.getValue(),
					ppcontactinfo_contact_id:this.txtPpContactInfoContactId.getValue(),
					
					//新加项
					shopNum:this.shopNum.getValue(),
					baseStation:this.baseStation.getValue(),
					managementCommittee:this.managementCommittee.getValue(),
					nearlyResource:this.nearlyResource.getValue(),
					nearlyHallName:this.nearlyHallName.getValue(),
					
					
					
					//gis信息
					/*grid_id:this.cmbDistrict.getValue(),
					longitude:this.txtAddressInfoLongitude.getValue(),
					latitude:this.txtAddressInfoLatitude.getValue(),
					icon_id:this.txtGisIconId.getValue(),
					gis_id:this.txtGisId.getValue(),*/
					grid_id:this.cmbGrid.getValue(),
					area_id:this.cmbRegion.getValue(),
					gis_id:this.txtGisId.getValue(),
					coords_info : this.txtCoordsInfo.getValue(),
					line_color : this.txtLineColor.getValue(),
					main_fill_color : this.txtMainFillColor.getValue(),
					type : this.txtGisType.getValue(),
					groupCustInfoID:this.txtGroupCustInfoID.getValue(),
					
					//物业信息
					property_company:this.txtPropertyCompany.getValue(),
					property_company_cust_id:this.txtPropertyCompany.getValue(),
					property_company_cust_name:this.txtCompanyInfoCustName.getValue()
				},
				success:function(resp){	
					this.scope.hide();
					GridParkInfo.List.instance.store.reload();
				}
			});
		},
		showSelector: function(event) {
			if (!this.userSelector) {
				this.userSelector = new Selector.User(this, '客户经理');
			}
			//console.info(this.users);
			this.userSelector.initUsers(this.users);
			this.userSelector.show();
		},
		
		setUsers: function(o) {	// for Selector.User callback
			if(o.length>0){
				this.users = o;
				this.txtUnitManager.setValue(this.users[0].name);
				this.txtUnitManagerUserId.setValue(this.users[0].id);
				this.selectUserId = this.users[0].id;
			}
		},
		initGridGis:function(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId){
			this.txtLineColor.setValue(lineColor);
			this.txtMainFillColor.setValue(mainFillColor);
			this.txtParkName.setValue(gridName);
			this.txtCoordsInfo.setValue(coordInfo);
			this.txtGroupCustInfoID.setValue(groupCustInfoID);//社区当中所包含的集团客户ID集
			this.txtGridId.setValue(gridId);
		},
		viewGis:function(){
			
			var unitId = this.txtUnitId.getValue();
			var areaId = this.cmbRegion.getValue();
			
			var layerType;
			if(unitId==null||unitId==""){
				layerType = 1;
				if(areaId==''){
					Utils.warn('请先选择区域！');
					return;
				}
			}else{
				layerType = 2;
			}
			
			var str = OMS.GIS_IP+'/gis_for_management.jsp?areaId=' + areaId + '&lineColor=' + this.txtLineColor.getValue() + 
			'&mainFillColor=' + this.txtMainFillColor.getValue() + 
			'&name='+this.txtParkName.getValue()+
			'&type=1'+
			'&did='+this.txtUnitId.getValue()+ 
			'&coordx='+this.txtCoordsInfo.getValue()+ '&layerType='+layerType;
			window.open(encodeURI(str), '_blank', 'toolbar=no,location=no,directories=no,scrollbars=no,menubar=no,width=1000,height=600,resizable=no,left=0,top=0, status=no');	
		}
		
});

//园区GIS 回调函数
 function initGridGis(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId){
	GridParkInfo.Detail.instance.initGridGis(lineColor,mainFillColor,gridName,coordInfo,groupCustInfoID,gridId);
};